grammar Mobinium;

options { output=AST; }


@header {
package com.thoughtworks.mobinium.parser;
}

@lexer::header {
package com.thoughtworks.mobinium.parser;
}

@members {

public void reportError(RecognitionException ex) {
	super.reportError(ex);
	throw new RuntimeException(ex);
}
}

statements
  : statement* EOF
  ;
  
statement
  : commandDeclaration
  ;
  
commandDeclaration 
  : 'application'^ Identifier
  | 'select'^ Identifier IdentifierInQuotes
  | 'choose'^ Identifier Identifier
  | 'type'^ Identifier IdentifierInQuotes
  | 'press'^ Identifier
  | 'back'^
  | assertionDeclaration
  | 'menu' Identifier
  | LINE_COMMENT
  ;
  
assertionDeclaration
  : 'assert'^ Identifier IdentifierInQuotes
  | 'assertListEmpty'^ Identifier
  | 'assertList'^ Identifier IdentifierInQuotes+
  ;
    
Identifier
   :   Letter (Letter)* 
   ;
   
IdentifierInQuotes
    : '"' Letter (Letter)*  '"' 
    ;  
  
IntegerLiteral
  : ('0' | '1'..'9' '0'..'9'*)
  ;  
    
Letter
	: 'a'..'z'|'A'..'Z'|'.'|'1'..'9'|'*'
	;
		
LINE_COMMENT
    : '//' ~('\n'|'\r')* '\r'? '\n'        
    ;
  
